//
//  BlockViewController.m
//  协议传值<带返回值.
//
//  Created by dllo on 16/8/4.
//  Copyright © 2016年 YMJ. All rights reserved.
//

#import "BlockViewController.h"

@interface BlockViewController ()
@property (nonatomic, strong) UITextField *textF;

@end

@implementation BlockViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(200, 200, 200, 50);
    button.backgroundColor = [UIColor redColor];
    [button setTitle:@"那你怎么过好?" forState:0];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    self.textF = [[UITextField alloc] initWithFrame:CGRectMake(0, 400, 414, 50)];
    _textF.backgroundColor = [UIColor redColor];
    _textF.textColor = [UIColor blackColor];
    [self.view addSubview:_textF];
    _textF.placeholder = @"我是BlockVC";
    _goodBlock(_textF.placeholder,_textF.backgroundColor);
    _badBlock();
    
    
    
    
}
// 实现方法1
- (void)returnTxt:(myBlock)block {
    _goodBlock = block;
}
// 实现方法2
- (void)sendValue:(youBlock)block {
    _badBlock = block;
}

- (void)buttonAction:(UIButton *)btn {
    CATransition *animation = [CATransition animation];
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
    animation.duration = 2;
    animation.type = kCATransitionPush;
    animation.subtype = kCATransitionFromBottom;
    [self.view.window.layer addAnimation:animation forKey:@"ff"];
    [self dismissViewControllerAnimated:NO completion:^{
        
        
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
